package org.blogwu.learn.multithread.chapter2.demo6;

public class VolatileTest2 {

    static class Thread1 extends Thread {

        static volatile boolean bb = true;

        @Override
        public void run() {
            while (bb) ;
            System.out.println("Thread over");
        }
    }

    public static void main(String[] args) {
        Thread1 t1 = new Thread1();
        t1.start();
        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("set false");
        Thread1.bb = false;
        System.out.println("set false over");
    }
}


